import { Outlet, history, useLocation, useModel } from "umi";
import "./index.css";
import { NavBar } from "antd-mobile";

export default function Layout() {
  const { name } = useModel('global')
  let location = useLocation();
  document.documentElement.setAttribute(
    'data-prefers-color-scheme',
    'dark'
  )
  const onBack = () => {
    history.back();
  };
  window.addEventListener('orientationchange', () => {
    history.go(0)
  })
  return (
    <>
      {location.pathname !== "/" && (
        <NavBar
          style={{ float: "left", color: "var(--color-white)", width: '100vw', boxSizing: "border-box" }}
          onBack={onBack}
        >
          {name}
        </NavBar>
      )}
      <Outlet />
    </>
  );
}
